package com.neusoft.ysu.his.mapper;

import com.neusoft.ysu.his.entity.Doc;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neusoft.ysu.his.entity.Seek;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2023-08-25
 */
@Mapper
public interface DocMapper extends BaseMapper<Doc> {

//可以尝试动态SQL语句
//    @Select("SELECT d.*\n" +
//            "FROM doc d\n" +
//            "JOIN sch s ON d.name = s.docname\n" +
//            "WHERE s."+"${week}"+" = #{noon} \n" +
//            "  AND d.level_id = #{leveId}\n" +
//            "  AND d.deptid = #{deptId}" +
//            "  AND d.delmark=0" +
//            "OR d.level_id = #{leveId}\n" +
//            "   AND d.deptid = #{deptId}\n" +
//            "   AND d.delmark= 0 \n" +
//            "   AND s."+"${week}"+" = 3 ")
// +
//         " OR d.level_id = #{leveId}\n" +
//         "              AND d.deptid = #{deptId}\n" +
//         "             AND d.delmark=0\n" +
//         " AND s.${week} = 3 "

    @Select("SELECT d.* \n" +
            "            FROM doc d \n" +
            "            JOIN sch s ON d.name = s.docname\n" +
            "            WHERE d.level_id = #{levelId}\n" +
            "              AND d.deptid = #{deptId}\n" +
            "             AND d.delmark=0\n" +
            "\t\t\t\t\t\t AND (s.${week} = #{noon} OR s.${week} = 3) AND d.worknum<d.patientnum\n")
    List<Doc> findDocToSee(@Param("week") String week, @Param("noon") int noon,@Param("levelId") int levelId,@Param("deptId") int deptId );


    @Select("select * from doc")
    @ResultMap("docMap")
    List<Doc> findName();
}
